package com.cost.controller;

import com.cost.service.CostRechargeService;
import com.rmb.mart.entity.cost.CostRecharge;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (CostRecharge)表控制层
 *
 * @author makejava
 * @since 2021-01-20 14:04:18
 */
@RestController
@RequestMapping("costRecharge")
public class CostRechargeController {
    /**
     * 服务对象
     */
    @Resource
    private CostRechargeService costRechargeService;


    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public CostRecharge selectOne(Long id) {
        return this.costRechargeService.queryById(id);
    }


    /**
     * 查询所用数据
     *
     * @return 所用数据
     */
    @GetMapping("selectAll")
    public List<CostRecharge> selectAll() {
        return this.costRechargeService.selectAll();
    }

    /**
     * 分页查询
     *
     * @param offset 初始页
     * @param limit 每页
     * @return 每页数据
     */
    @GetMapping("selectAllByLimit")
    public List<CostRecharge> selectAllByLimit(int offset, int limit){
        return this.costRechargeService.queryAllByLimit(offset,limit);
    }

    /**
     * 条件查询
     * @param costRecharge 条件 
     * @return 条件查询数据
     */
    @PostMapping("selectAllCondition")
    public List<CostRecharge> selectAllCondition(@RequestBody CostRecharge costRecharge){
        return this.costRechargeService.selectAllCondition(costRecharge);
    }

    @GetMapping("/recharg")
    public void recharg(Long id,Double balance){
       this.costRechargeService.recharg(id,balance);
    }

}
